Skip to content

feat(desktop): share the Local Runtime Host - #3972

Merged
M4n5ter merged 7 commits into
apache:mainfrom
M4n5ter:feat/desktop-local-host-remote-access
Aug 27, 2026
Merged

feat(desktop): share the Local Runtime Host#3972
M4n5ter merged 7 commits into
apache:mainfrom
M4n5ter:feat/desktop-local-host-remote-access

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Aug 27, 2026

Copy link
Copy Markdown
Member
English

Summary

Let a user expose the current computer's Local Runtime Host to another Maka Desktop without creating a second Host or copying its State Root

  • hands the existing Local Host from the ephemeral Desktop child to the OS-managed service
  • keeps Local IPC and experimental Direct peer active on the same Host
  • adds versioned, one-time Owner connection codes and an atomic import flow
  • keeps disabling connectivity separate from uninstalling the service or revoking credentials

#3950 is merged; this PR is based on main

Refs #3842

Verification

  • npm run typecheck
  • npm run lint -- --diagnostic-level=error
  • npm run format:check
  • npm run build
  • npm run check:stale
  • npm run check:asf-headers
  • npm run astryx:surface-inventory
  • affected CLI, Runtime Host, and Desktop test suites
  • real two-Desktop connection-code import over Direct peer, including disable, re-enable, and service uninstall
  • Electron UI checked through CDP with isolated profiles

UI

Before:

After:

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex assisted with implementation, tests, documentation, and verification under the contributor's direction

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No
中文

摘要

允许用户把当前电脑的 Local Runtime Host 提供给另一台 Maka Desktop 使用,同时不创建第二个 Host,也不复制 State Root

  • 将现有 Local Host 从 Desktop 临时子进程交接给操作系统托管服务
  • 同一个 Host 同时保留 Local IPC 与实验性的 Direct peer listener
  • 增加版本化、一次性的 Owner 连接码和原子导入流程
  • 明确区分关闭连接方式、卸载服务与撤销凭据

#3950 已合并;本 PR 现基于 main

关联 #3842

验证

  • npm run typecheck
  • npm run lint -- --diagnostic-level=error
  • npm run format:check
  • npm run build
  • npm run check:stale
  • npm run check:asf-headers
  • npm run astryx:surface-inventory
  • 受影响的 CLI、Runtime Host 与 Desktop 测试套件
  • 使用两个真实 Desktop 通过 Direct peer 导入连接码,并验证关闭、重新开启和卸载服务
  • 使用隔离 profile 通过 CDP 检查 Electron UI

界面

修改前:

修改后:

AI 使用

  • 没有生成式工具作出实质贡献
  • 生成式工具作出了实质贡献

工具与范围:OpenAI Codex 在贡献者指导下协助实现、测试、文档与验证

检查清单

  • 测试覆盖本次变更,并会在缺少变更时失败
  • lint、format、typecheck 与受影响测试套件均已在本地通过

本 PR 是否改变行为?

  • 是——已在摘要中说明

@github-actions github-actions Bot added the effort/XL Over 1000 readable lines label Aug 27, 2026
@M4n5ter
M4n5ter force-pushed the feat/desktop-local-host-remote-access branch from d974723 to b452e05 Compare August 27, 2026 06:35
@M4n5ter
M4n5ter marked this pull request as ready for review August 27, 2026 08:15

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed the current exact head 6f57620a3f11f42f47e06a901bd52ceb7565e2d6. The recovery changes close the previous retry lock, but the PR is still not ready to approve because the owner-credential lifecycle remains incomplete.

Findings

P1 — Claimed connection codes accumulate durable full-owner credentials without a local revocation path.

Both initial setup and every later connection code create a fresh desktop-owner:<uuid> principal (apps/desktop/src/main/runtime-host-local-remote-access.ts:251 and :573). Credential finalization revokes existing active credentials only when their principal matches (packages/runtime-host/src/server/access-authority.ts:361-366), so these random principals never replace one another.

I exercised the current access-authority path by preparing and finalizing two codes. The durable access file retained two distinct active Remote Owner credentials, each bound to a different Client instance. These owners receive the complete REMOTE_OWNER_OPERATION_GRANTS, but Local Settings exposes only “New connection code”, “Turn off”, and “Remove background service” (runtime-host-profiles-section.tsx:391-405); it has no authorization list or per-client revoke action. Turning off Direct peer access or uninstalling the service also does not revoke credentials stored in the State Root.

Before merge, either make this one stable Local-share owner slot that can be replaced and revoked, or explicitly support multiple owners with understandable device labels, an authorization/status list, and individual revocation.

P2 — Connection-code failures are not actionable in English.

The import dialog sends every failure through settingsActionErrorMessage() (runtime-host-connection-code-dialog.tsx:52-61). For English, that helper does not classify the error and then returns unknownError even after safely redacting the original message (settings-error-copy.ts:31-35). A user therefore cannot distinguish malformed, expired, already-claimed, unreachable, or root-mismatch failures. Preserve typed failure reasons across the bridge and map them to safe, specific recovery guidance.

P2 — The UI does not explain the security and connectivity contract.

The current copy says only that the feature uses an experimental Direct peer and that the code is one-time. It should also state that there is no fallback transport, an unclaimed code expires after 15 minutes, the first claimant receives full Owner authority, and turning off Direct access or removing the service does not revoke an already claimed credential.

Verification

The new persisted handoff, peer-change, uninstall, and cleanup intents now recover through startup or the enabled recovery action, so the previous unavailable UI dead end is closed. Affected builds and 121 focused Desktop, CLI, and Runtime Host tests passed. All applicable hosted checks are successful; the conditional Eval job is skipped. The merge result against current main (45824cc78eaf0e02bbd07dbd6fd46adfd38bd985) is clean.


Posted by an automated review agent operated by @WAWQAQ. This is not an
independent human review and does not satisfy the committer review required by
CONTRIBUTING.md. A human is accountable for this comment — please push back if
anything here is wrong.

简体中文

本条评论由 @WAWQAQ 运行的自动化审查程序发出。它不构成 CONTRIBUTING.md
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。

@M4n5ter
M4n5ter force-pushed the feat/desktop-local-host-remote-access branch from 6f57620 to 491efd4 Compare August 27, 2026 09:24
@M4n5ter

M4n5ter commented Aug 27, 2026

Copy link
Copy Markdown
Member Author
English

Addressed the confirmed findings at 491efd4ed.

  • Local sharing now uses one stable principal. A successfully claimed connection code atomically replaces the previous credential for that sharing authority instead of accumulating full-owner credentials.
  • Settings now exposes Revoke shared access independently from Direct peer connectivity and service installation. Revocation disconnects the authorized Desktop and invalidates any outstanding code for the same authority.
  • Connection-code import now preserves bounded failure reasons across IPC and provides specific guidance for invalid, expired/already-used, unreachable, mismatched/incompatible, and unknown outcomes.
  • The dialogs now state the 15-minute expiry, one-time claim, Owner authority, and lack of a fallback transport. Disable and uninstall confirmations explicitly state that granted access is retained unless separately revoked.

The branch was rebased onto current main. Desktop lint, formatting, typecheck, Knip, the full 1,590-test Desktop suite, and the focused post-rebase tests pass.

简体中文

已在 491efd4ed 处理确认成立的问题。

  • Local sharing 现在使用唯一稳定的 principal。连接码成功领取后会原子替换该共享 authority 的旧 credential,不再累积完整 Owner credential。
  • 设置中新增了独立于 Direct peer 连接和后台服务安装状态的 撤销共享访问。撤销会断开已授权 Desktop,并使该 authority 尚未使用的连接码失效。
  • 连接码导入会通过 IPC 保留有界的失败原因,并分别提示格式无效、过期或已使用、Host 不可达、目标不匹配或不兼容,以及结果未知。
  • 对话框现已明确说明 15 分钟有效期、只能领取一次、领取者获得 Owner 权限以及不存在 fallback transport。关闭连接和卸载确认也明确说明:除非单独撤销,否则已授予的访问仍会保留。

分支已 rebase 到最新 main。Desktop lint、格式检查、typecheck、Knip、完整的 1,590 项 Desktop 测试以及 rebase 后的相关测试均通过。

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed the current exact head 491efd4ed4b71e6a09b09ce79bd773d04c38c032. The previous owner-lifecycle and connection-code UX findings are addressed, but one revocation race still makes this unsafe to approve.

P1 — “Revoke shared access” can report success while a newly claimed Owner remains active.

The Desktop implementation first lists credentials and selects the currently active credential, then revokes that credential by ID (apps/desktop/src/main/runtime-host-local-remote-access.ts:314-336). These are separate Host operations.

If an outstanding connection code is claimed between those operations, credential finalization removes the listed active credential and activates the new same-principal credential (packages/runtime-host/src/server/access-authority.ts:338-380). The later revoke of the stale ID returns { revoked: false } (access-authority.ts:300-305), but the Desktop ignores that result, clears its sharedAccess snapshot flag, and displays “Shared access revoked.” The newly claimed credential remains a durable Remote Owner with the full Owner grants.

I reproduced this with the current production access-authority implementation: after finalizing the pending successor and revoking the previously listed credential ID, the revoke result was false and the durable access file still contained the successor as active, bound to the new Client instance. The added Desktop test always mocks { revoked: true }, so it does not cover finalization racing between list and revoke.

Please make revocation a single Host-owned atomic revoke-by-principal operation. If that is not practical, the caller must at least inspect the revoke result and use bounded re-list/retry and postcondition verification until no matching active or pending credential remains; only then should the UI report success.


Posted by an automated review agent operated by @WAWQAQ. This is not an
independent human review and does not satisfy the committer review required by
CONTRIBUTING.md. A human is accountable for this comment — please push back if
anything here is wrong.

简体中文

本条评论由 @WAWQAQ 运行的自动化审查程序发出。它不构成 CONTRIBUTING.md
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。

Move the Local Host to its existing managed-service lifecycle when remote access is enabled, while retaining Local IPC and the same State Root. Add one-time Direct peer connection codes and Desktop import/export UX without creating a second Host identity.

Generated-by: OpenAI Codex
Bind a pairing candidate to the first Desktop that finalizes it, and reconnect that Client onto the resulting Owner authority. Recover interrupted managed-service handoffs from a durable journal and close operator lifecycle races while consolidating framed child handling.

Generated-by: OpenAI Codex
Persist exact peer and uninstall intents so interrupted Desktop operations resume safely. Preserve credential reload invariants and explicit active-work interruption authority.

Generated-by: OpenAI Codex
Make managed setup, peer changes, and uninstall converge on exact persisted targets across interruption boundaries. Revalidate pairing and peer authority before admitting a connection.

Generated-by: OpenAI Codex
Use one replaceable Local sharing principal and expose explicit revocation independently from connectivity and service lifecycle. Preserve bounded connection-code failure reasons for localized recovery guidance.
Serialize principal-wide revocation with pairing finalization so a replacement credential cannot survive stale credential selection. Have Desktop invoke the local-owner-only operation directly.

Generated-by: OpenAI Codex
@M4n5ter
M4n5ter force-pushed the feat/desktop-local-host-remote-access branch from 491efd4 to 7e3411b Compare August 27, 2026 10:35
@M4n5ter

M4n5ter commented Aug 27, 2026

Copy link
Copy Markdown
Member Author
English

The race is valid and is fixed at 7e3411b46.

Revocation is now the Local Owner-only access.principal.revoke Host operation. It runs in the same serialized access-authority mutation queue as pairing finalization and removes every active or pending credential for the stable Local-sharing principal in one durable commit. Therefore:

  • if finalization commits first, principal revocation includes the newly active credential;
  • if revocation commits first, it removes the pending credential and the later finalization fails;
  • an unknown commit outcome is still surfaced as an error, so Desktop cannot report a false success.

Desktop now calls this operation directly instead of listing credentials and revoking a stale ID. The operation is deliberately not granted to Remote Owners. A focused authority test covers both orderings and verifies that neither credential remains authenticatable; the Desktop test verifies the principal-scoped request.

The branch is rebased onto current main. Repository lint, all-workspace typecheck, and the focused Runtime Host/Desktop tests pass.

简体中文

该竞态成立,已在 7e3411b46 修复。

撤销现在由仅限 Local Owner 的 Host 操作 access.principal.revoke 完成。它与 pairing finalization 共用同一个串行 access-authority mutation queue,并在一次持久提交中撤销稳定 Local-sharing principal 的全部 active/pending credentials。因此:

  • finalization 先提交时,principal 撤销会包含刚激活的新 credential;
  • 撤销先提交时,pending credential 会被删除,之后的 finalization 必然失败;
  • commit outcome unknown 仍会作为错误返回,Desktop 不会错误报告撤销成功。

Desktop 不再先列举 credential 再按可能过时的 ID 撤销,而是直接调用 principal 级操作。该操作没有授予 Remote Owner。定向 authority 测试覆盖了两种顺序并验证两份 credential 最终均无法认证;Desktop 测试验证了 principal-scoped 请求。

分支已 rebase 到最新 main。仓库 lint、全 workspace typecheck 和相关 Runtime Host/Desktop 测试均通过。

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed the current exact head 7e3411b4694b01799b443f464ceeff85f39b090e. The previously reported owner-lifecycle, recovery, connection-code UX, security-copy, and revocation-race findings are closed, and I found no remaining P0–P2 issue.

The final change makes shared-access revocation one Host-owned principal operation serialized with pairing finalization. Both possible orderings leave the old and pending/new credentials unable to authenticate, persistence ambiguity still fails closed, the operation is unavailable to Remote Owners, and compatibility epoch 55 prevents mixed-version use. Focused Runtime Host and Desktop verification passed. The branch is directly based on current main, and its merge tree is clean.

The hosted test and quality jobs were still queued when I submitted this review. This approval covers the code review; merging should still wait for all required hosted checks to finish successfully on this exact head.


Posted by an automated review agent operated by @WAWQAQ. This is not an
independent human review and does not satisfy the committer review required by
CONTRIBUTING.md. A human is accountable for this comment — please push back if
anything here is wrong.

简体中文

本条评论由 @WAWQAQ 运行的自动化审查程序发出。它不构成 CONTRIBUTING.md
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。

Keep the preset boundary assertion synchronized with the new Local Owner-only principal revocation operation.

Generated-by: OpenAI Codex
@M4n5ter
M4n5ter merged commit 4cc781f into apache:main Aug 27, 2026
15 of 16 checks passed
@M4n5ter
M4n5ter deleted the feat/desktop-local-host-remote-access branch August 27, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Over 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants